
#import "NSImage+Conversion.h"

@implementation NSImage(CreatingFromCGImages)

- initWithCGImage:(CGImageRef)cgImage {
    if (cgImage) {
        NSBitmapImageRep *bitmapImageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; // Take advantage of NSBitmapImageRep's new -initWithCGImage: initializer, which is new in Leopard.
        if (bitmapImageRep) {
            self = [self initWithSize:[bitmapImageRep size]];
            [self addRepresentation:bitmapImageRep];
            [bitmapImageRep release];
            return self;
        }
    }
    [self release];
    return nil;
}

@end
